//
//  FreebaseSuggest.h
//
//  Created by Alec Flett on 11/18/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "Freebase.h"
#import "FreebaseDetail.h"
#import "FreebaseSuggestSearch.h"

@class FreebaseSuggest, FreebaseSuggestSearch;

@protocol FreebaseSuggestDelegate

-(void)suggest:(FreebaseSuggest*)suggest itemSelected:(NSDictionary*)itemSelected;

@end

@interface FreebaseSuggest : UITableViewController 
<UITableViewDelegate, UITableViewDataSource, FreebaseSuggestDelegate> {
    NSObject<FreebaseSuggestDelegate>* _delegate;
    BOOL _appearedOnce;
    FreebaseSuggestSearch *_search;
    FreebaseDetail* _itemDetail;
    UIView* _itemDetailParentView;
    NSDictionary *_newItemType;
    
    FreebaseSuggest* _typeChooser;
    
    // this is different than UIViewController.searchDisplayController!
    UISearchDisplayController* _searchController;
    
    BOOL _showChooseType;    
    BOOL _showDetail;
}

- (IBAction)doneClicked;
- (IBAction)cancelClicked;
- (IBAction)chooseTypeClicked;


// comes from FreebaseSuggestDelegate
- (void)itemSelected:(NSDictionary*)item;

//
// properties that affect the behavior
//
// a MQL-filter for search or geosearch
@property(nonatomic, retain) NSString* mqlFilter;

@property(nonatomic, retain) NSString* mqlOutput;

// allow a "Create New..." button
@property(nonatomic, assign) BOOL allowCreateNew;

// allow geolocation
@property(nonatomic, assign) BOOL allowGeolocation;

// allow the user to show the topic detail?
@property(nonatomic, assign) BOOL showDetail;

// defaults to "/common/topic"
@property(nonatomic, retain) NSString* preferredType;

// defaults to "False"
@property(nonatomic, assign) BOOL strictType;

//
// everything else is private...
//

@property(nonatomic, retain) IBOutlet FreebaseSuggestSearch* search;

// delegate that will get told when something is suggested
@property(nonatomic, retain) NSObject<FreebaseSuggestDelegate>* delegate;

// the currently selected topic
@property(nonatomic, retain) NSDictionary* currentItem;


// All of the below are just for XIB setup

// The UIViewController showing the current
@property(nonatomic, retain) IBOutlet FreebaseDetail* itemDetail;

// The UIView that will contain itemDetail
@property(nonatomic, retain) IBOutlet UIView* itemDetailParentView;

@end
